package com.example.basicknowledge.带返回值的跳转;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.example.basicknowledge.R;

public class ReceiveResultJump extends AppCompatActivity {
    static final private int GET_CODE = 0;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.receive_result_jump);

        Button button = (Button)findViewById(R.id.button4);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(ReceiveResultJump.this, NextActivity.class);
                startActivityForResult(intent,GET_CODE);
            }
        });
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == GET_CODE) {
            TextView textView = (TextView)findViewById(R.id.textView6);
            textView.setText(data.getAction());
        }
    }
}
